library(groundhog)
## Loaded 'groundhog' (version:2.0.1) using R-4.2.1
## Tips and troubleshooting: https://groundhogR.com
pkgs <-  c("corrr","tidyverse","lme4","lmerTest", "ggeffects", "sjPlot", "insight", "data.table", "here", "arrow", "ggpubr", "wesanderson")
library(grid)
groundhog.day <- '2022-07-25'
groundhog.library(pkgs, groundhog.day)
## Registered S3 method overwritten by 'seriation':
##   method         from 
##   reorder.hclust gclus
## Succesfully attached 'corrr_0.4.3'
## Registered S3 methods overwritten by 'readr':
##   method                    from 
##   as.data.frame.spec_tbl_df vroom
##   as_tibble.spec_tbl_df     vroom
##   format.col_spec           vroom
##   print.col_spec            vroom
##   print.collector           vroom
##   print.date_names          vroom
##   print.locale              vroom
##   str.col_spec              vroom
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6     ✔ purrr   0.3.4
## ✔ tibble  3.1.8     ✔ dplyr   1.0.9
## ✔ tidyr   1.2.0     ✔ stringr 1.4.0
## ✔ readr   2.1.2     ✔ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## Succesfully attached 'tidyverse_1.3.2'
## 
## Loading required package: Matrix
## 
## 
## Attaching package: 'Matrix'
## 
## 
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
## 
## 
## Succesfully attached 'lme4_1.1-30'
## 
## 
## Attaching package: 'lmerTest'
## 
## 
## The following object is masked from 'package:lme4':
## 
##     lmer
## 
## 
## The following object is masked from 'package:stats':
## 
##     step
## 
## 
## Succesfully attached 'lmerTest_3.1-3'
## 
## Succesfully attached 'ggeffects_1.1.2'
## 
## Succesfully attached 'sjPlot_2.8.10'
## 
## Succesfully attached 'insight_0.18.0'
## 
## 
## Attaching package: 'data.table'
## 
## 
## The following objects are masked from 'package:dplyr':
## 
##     between, first, last
## 
## 
## The following object is masked from 'package:purrr':
## 
##     transpose
## 
## 
## Succesfully attached 'data.table_1.14.2'
## 
## here() starts at /Users/jacobelder/Documents/GitHub/NormIdeol
## 
## Succesfully attached 'here_1.0.1'
## 
## 
## Attaching package: 'arrow'
## 
## 
## The following object is masked from 'package:utils':
## 
##     timestamp
## 
## 
## Succesfully attached 'arrow_8.0.0'
## 
## Succesfully attached 'ggpubr_0.4.0'
## 
## Succesfully attached 'wesanderson_0.3.6'
here::i_am("main/Analysis/publicationPlots.Rmd")
## here() starts at /Users/jacobelder/Documents/GitHub/NormIdeol
devtools::source_url("https://raw.githubusercontent.com/JacobElder/MiscellaneousR/master/plotCommAxes.R")
## ℹ SHA-1 hash of file is "374a4de7fec345d21628a52c0ed0e4f2c389df8e"
objectName <- function(input) {
  deparse(match.call()$input)
}
#study 1
longDf1 <- read_parquet(here("main","data","PFfullDf.parquet"))
distDf1 <- read_parquet(here("main","data","distanceDf.parquet"))
varDf1 <- read_parquet(here("main","data","varDf1.parquet"))
study1_ind <- read.csv(here("main","data","Study1_indDiff.csv"))
study1_ind<- study1_ind[,c(2, 4,5,6,7,8,9)]

longDf1 <- merge(longDf1, study1_ind, by = c("subID"), all.x = T)
longDf1$partyN <- as.factor(longDf1$partyN)
longDf1$Rep <- as.factor(longDf1$Rep)
contrasts(longDf1$Rep) <- contr.sum(3)
longDf1$RepN <- as.factor(longDf1$RepN)
longDf1$RepN <- relevel(longDf1$RepN,"In")
longDf1$Info <- as.factor(longDf1$Info)
contrasts(longDf1$Info) <- contr.sum(2)
longDf1$partyN <- as.factor(longDf1$partyN)
contrasts(longDf1$partyN) <- contr.sum(2)
demDf <- subset(longDf1, partyN == "Dem")
repDf <- subset(longDf1, partyN == "Rep")
longDf1$politStre <- as.factor(abs(4-longDf1$Polit))
InfoDf1 <- subset(longDf1, Info == "Info")
issueDf1 <- longDf1[!duplicated(longDf1$issues),]
distDf1$polStrength <- as.factor(abs(4-distDf1$Polit))
#study 2
longDf2 <- read_parquet(here("main","data","PFfullDf2.parquet"))
distDf2 <- read_parquet(here("main","data","distanceDf2.parquet"))
varDf2 <- read_parquet(here("main","data","varDf2.parquet"))
study2_ind <- read.csv(here("main","data","Study2_indDiff.csv"))
study2_ind<- study2_ind[,c(2:11, 13:15)]
longDf2 <- merge(longDf2, study2_ind, by = c("subID"), all.x = T)

longDf2$partyN <- as.factor(longDf2$partyN)
longDf2$Rep <- as.factor(longDf2$Rep)
longDf2$Rep <- factor(longDf2$Rep, c("Non","Rep","Dem"))
longDf2$Rep <- relevel(longDf2$Rep,"Non")
contrasts(longDf2$Rep) <- contr.sum(3)
longDf2$RepN <- as.factor(longDf2$RepN)
longDf2$RepN <- relevel(longDf2$RepN,"In")
longDf2$Info <- as.factor(longDf2$Info)
contrasts(longDf2$Info) <- contr.sum(2)
longDf2$partyN <- as.factor(longDf2$partyN)
contrasts(longDf2$partyN) <- contr.sum(2)
demDf <- subset(longDf2, partyN == "Dem")
repDf <- subset(longDf2, partyN == "Rep")
longDf2$politStre <- as.factor(abs(4-longDf2$Polit))
InfoDf2 <- subset(longDf2, Info == "Info")
issueDf2 <- longDf2[!duplicated(longDf2$issues),]
plotswd <- ("/Volumes/GoogleDrive/My Drive/Volumes/Research Project/Preference Falsification/1+2Comb/Plots/")

Info and Similarity

Study 1

m <- lmer( dist ~ corr * Info + ( corr | subID), data = distDf1, control=lmerControl(optimizer="bobyqa",
                                optCtrl=list(maxfun=2e5)))
summary(m)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dist ~ corr * Info + (corr | subID)
##    Data: distDf1
## Control: lmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
## REML criterion at convergence: 7263613
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.9079 -0.7748 -0.1156  0.6898  4.4950 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr 
##  subID    (Intercept) 0.2388   0.4887        
##           corr        2.0669   1.4377   -0.66
##  Residual             2.9317   1.7122        
## Number of obs: 1854945, groups:  subID, 384
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)    2.32162    0.03531 381.92951  65.745   <2e-16 ***
## corr          -1.69016    0.10389 382.00480 -16.269   <2e-16 ***
## InfoNon       -0.03438    0.04994 381.93358  -0.689   0.4916    
## corr:InfoNon   0.32378    0.14692 382.00867   2.204   0.0281 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) corr   InfoNn
## corr        -0.655              
## InfoNon     -0.707  0.463       
## corr:InfoNn  0.463 -0.707 -0.655
p <- ggpredict(m, c("corr","Info"))
Sim.Info.S1 <-ggplot(p, aes(x, predicted)) +  geom_line(aes(linetype=group, color=group)) + geom_ribbon(aes(ymin=conf.low, ymax=conf.high, fill=group), alpha=0.15) + scale_linetype_discrete(labels = c("Group Norms","No Group Norms")) + scale_color_manual(labels = c("Group Norms","No Group Norms"), values = wes_palette("Darjeeling1")) + scale_fill_manual( 
                      labels=c("Group Norms","No Group Norms"), values = wes_palette("Darjeeling1")) + theme(
    legend.position = c(.6, .65),
    legend.justification = c("left", "bottom"),
    legend.box.just = "left",
    legend.margin = margin(6, 6, 6, 6)
    ) + theme(axis.text=element_text(size=12),
        axis.title=element_text(size=12,face="bold")) + theme(legend.text = element_text(size=12)) + theme(panel.border = element_rect(colour = "black", fill = NA, size =1)) + theme(legend.title = element_blank()) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black")) +
  xlab("Issue Similarity") + ylab("Rating Dissimilarity")
Sim.Info.S1

Raw data

ggpredict(m, c("corr","Info"))%>% plot(add.data=T) + labs(title="Raw Data",x="Issue Similarity",y="Evaluation Similarity")

Study 2

m <- lmer( dist ~ corr * Info + ( corr | subID), data = distDf2, control=lmerControl(optimizer="bobyqa",
                                optCtrl=list(maxfun=2e5)))
summary(m)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dist ~ corr * Info + (corr | subID)
##    Data: distDf2
## Control: lmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
## REML criterion at convergence: 17357713
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.0270 -0.7620 -0.1053  0.7012  4.1755 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr 
##  subID    (Intercept) 101.5    10.08         
##           corr        742.2    27.24    -0.67
##  Residual             735.7    27.12         
## Number of obs: 1838503, groups:  subID, 380
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)   38.94716    0.73737 377.98588  52.819   <2e-16 ***
## corr         -31.58797    1.99453 377.95846 -15.837   <2e-16 ***
## InfoNon        0.08693    1.03467 377.99769   0.084   0.9331    
## corr:InfoNon   4.90766    2.79870 377.97216   1.754   0.0803 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) corr   InfoNn
## corr        -0.672              
## InfoNon     -0.713  0.479       
## corr:InfoNn  0.479 -0.713 -0.672
p <- ggpredict(m, c("corr","Info"))
Sim.Info.S2 <-ggplot(p, aes(x, predicted)) +  geom_line(aes(linetype=group, color=group)) + geom_ribbon(aes(ymin=conf.low, ymax=conf.high, fill=group), alpha=0.15) + scale_linetype_discrete(labels = c("Group Norms","No Group Norms")) + scale_color_manual(labels = c("Group Norms","No Group Norms"), values = wes_palette("Darjeeling1")) + scale_fill_manual( 
                      labels=c("Group Norms","No Group Norms"), values = wes_palette("Darjeeling1")) + theme(
    legend.position = c(.6, .65),
    legend.justification = c("left", "bottom"),
    legend.box.just = "left",
    legend.margin = margin(6, 6, 6, 6)
    ) + theme(axis.text=element_text(size=12),
        axis.title=element_text(size=12,face="bold")) + theme(legend.text = element_text(size=12)) + theme(panel.border = element_rect(colour = "black", fill = NA, size =1)) + theme(legend.title = element_blank()) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black")) +
  xlab("Issue Similarity") + ylab("Rating Dissimilarity") + scale_x_continuous(breaks=seq(-1,1,1))
Sim.Info.S2

ggpredict(m, c("corr","Info"))%>% plot(add.data=T) + labs(title="Raw Data",x="Issue Similarity",y="Evaluation Similarity")

Sim.Info.Comb <- plotCommAxes(Sim.Info.S1, Sim.Info.S2, xaxis = "Issue Similarity", yaxis = "Rating Dissimilarity")
Sim.Info.Comb

ggsave(paste0(plotswd,objectName(Sim.Info.Comb),".png"), width = 9, height = 6, dpi=500, units="in")
ggsave(paste0(plotswd,objectName(Sim.Info.Comb),".tiff"), width = 9, height = 6, dpi=500, units="in")

Affective Polarization and Similarity

Study 1

m <- lmer( dist ~ corr * affPol + ( corr | subID), data = distDf1, control=lmerControl(optimizer="bobyqa",
                                optCtrl=list(maxfun=2e5)))
summary(m)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dist ~ corr * affPol + (corr | subID)
##    Data: distDf1
## Control: lmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
## REML criterion at convergence: 7245702
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.9052 -0.7751 -0.1160  0.6905  4.4931 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr 
##  subID    (Intercept) 0.2155   0.4642        
##           corr        1.9184   1.3850   -0.62
##  Residual             2.9340   1.7129        
## Number of obs: 1849995, groups:  subID, 383
## 
## Fixed effects:
##               Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)  2.070e+00  4.341e-02  3.810e+02  47.674  < 2e-16 ***
## corr        -8.919e-01  1.295e-01  3.811e+02  -6.886 2.38e-11 ***
## affPol       4.212e-03  6.489e-04  3.810e+02   6.491 2.66e-10 ***
## corr:affPol -1.143e-02  1.936e-03  3.810e+02  -5.902 7.96e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) corr   affPol
## corr        -0.619              
## affPol      -0.837  0.518       
## corr:affPol  0.518 -0.837 -0.619
p <- ggpredict(m, c("corr","affPol"))
Sim.AffPol.S1 <-ggplot(p, aes(x, predicted)) +  geom_line(aes(linetype=group, color=group)) + geom_ribbon(aes(ymin=conf.low, ymax=conf.high, fill=group), alpha=0.15) + scale_linetype_discrete(labels = c("Low Aff. Pol.","Medium Aff. Pol.", "High Aff. Pol.")) + scale_color_manual(labels = c("Low Aff. Pol.","Medium Aff. Pol.", "High Aff. Pol."), values = wes_palette("Darjeeling1")) + scale_fill_manual( 
                      labels=c("Low Aff. Pol.","Medium Aff. Pol.", "High Aff. Pol."), values = wes_palette("Darjeeling1")) + theme(
    legend.position = c(.6, .65),
    legend.justification = c("left", "bottom"),
    legend.box.just = "left",
    legend.margin = margin(6, 6, 6, 6)
    ) + theme(axis.text=element_text(size=12),
        axis.title=element_text(size=12,face="bold")) + theme(legend.text = element_text(size=12)) + theme(panel.border = element_rect(colour = "black", fill = NA, size =1)) + theme(legend.title = element_blank()) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black")) +
  xlab("Issue Similarity") + ylab("Rating Dissimilarity")
Sim.AffPol.S1

ggpredict(m, c("corr","affPol"))%>% plot(add.data=T) + labs(title="Raw Data",x="Issue Similarity",y="Evaluation Similarity")

Study 2

m <- lmer( dist ~ corr * affPol + ( corr | subID), data = distDf2, control=lmerControl(optimizer="bobyqa",
                                optCtrl=list(maxfun=2e5)))
summary(m)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dist ~ corr * affPol + (corr | subID)
##    Data: distDf2
## Control: lmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
## REML criterion at convergence: 17357678
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.0269 -0.7620 -0.1054  0.7012  4.1752 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr 
##  subID    (Intercept)  87.43    9.35         
##           corr        686.52   26.20    -0.63
##  Residual             735.74   27.12         
## Number of obs: 1838503, groups:  subID, 380
## 
## Fixed effects:
##              Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)  33.43278    0.85958 377.98743  38.894  < 2e-16 ***
## corr        -17.45695    2.40945 377.96187  -7.245 2.45e-12 ***
## affPol        0.10659    0.01367 377.99089   7.796 6.27e-14 ***
## corr:affPol  -0.22319    0.03833 377.96296  -5.823 1.23e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) corr   affPol
## corr        -0.632              
## affPol      -0.829  0.524       
## corr:affPol  0.524 -0.829 -0.632
p <- ggpredict(m, c("corr","affPol"))
Sim.AffPol.S2 <-ggplot(p, aes(x, predicted)) +  geom_line(aes(linetype=group, color=group)) + geom_ribbon(aes(ymin=conf.low, ymax=conf.high, fill=group), alpha=0.15) + scale_linetype_discrete(labels = c("Low Aff. Pol.","Medium Aff. Pol.", "High Aff. Pol.")) + scale_color_manual(labels = c("Low Aff. Pol.","Medium Aff. Pol.", "High Aff. Pol."), values = wes_palette("Darjeeling1")) + scale_fill_manual( 
                      labels=c("Low Aff. Pol.","Medium Aff. Pol.", "High Aff. Pol."), values = wes_palette("Darjeeling1")) + theme(
    legend.position = c(.6, .65),
    legend.justification = c("left", "bottom"),
    legend.box.just = "left",
    legend.margin = margin(6, 6, 6, 6)
    ) + theme(axis.text=element_text(size=12),
        axis.title=element_text(size=12,face="bold")) + theme(legend.text = element_text(size=12)) + theme(panel.border = element_rect(colour = "black", fill = NA, size =1)) + theme(legend.title = element_blank()) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black")) +
  xlab("Issue Similarity") + ylab("Rating Dissimilarity")  + scale_x_continuous(breaks=seq(-1,1,1))
Sim.AffPol.S2

ggpredict(m, c("corr","affPol"))%>% plot(add.data=T) + labs(title="Raw Data",x="Issue Similarity",y="Evaluation Similarity")

Sim.AffPol.Comb <- plotCommAxes(Sim.AffPol.S1, Sim.AffPol.S2, xaxis = "Issue Similarity", yaxis = "Rating Dissimilarity")
Sim.AffPol.Comb

ggsave(paste0(plotswd,objectName(Sim.AffPol.Comb),".png"), width = 9, height = 6, dpi=500, units="in")
ggsave(paste0(plotswd,objectName(Sim.AffPol.Comb),".tiff"), width = 9, height = 6, dpi=500, units="in")
Sim.Comb <- ggarrange(Sim.AffPol.Comb, Sim.Info.Comb, nrow = 2, ncol = 1)
Sim.Comb

ggsave(paste0(plotswd,objectName(Sim.Comb),".png"), width = 10, height = 9, dpi=500, units="in")
ggsave(paste0(plotswd,objectName(Sim.Comb),".tiff"), width = 10, height = 9, dpi=500, units="in")

Ideological Polarization

Info

Study 1

m <- lmer( eval ~ inMinOut*Info + ( inMinOut | subID) + (1 | issues), data = longDf1, control=lmerControl(optimizer="bobyqa",
                                optCtrl=list(maxfun=2e5)))
summary(m)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: eval ~ inMinOut * Info + (inMinOut | subID) + (1 | issues)
##    Data: longDf1
## Control: lmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
## REML criterion at convergence: 141384.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.4206 -0.6319  0.0958  0.6610  4.3618 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr 
##  subID    (Intercept) 0.1246   0.3531        
##           inMinOut    2.0690   1.4384   -0.45
##  issues   (Intercept) 1.0658   1.0324        
##  Residual             2.3036   1.5178        
## Number of obs: 37917, groups:  subID, 384; issues, 100
## 
## Fixed effects:
##                 Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)      4.71874    0.10526 104.82038  44.828  < 2e-16 ***
## inMinOut         2.15317    0.07651 380.61536  28.141  < 2e-16 ***
## Info1           -0.01271    0.01973 380.43750  -0.644  0.51981    
## inMinOut:Info1   0.20690    0.07651 380.62042   2.704  0.00716 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) inMnOt Info1 
## inMinOut    -0.073              
## Info1        0.000  0.000       
## inMnOt:Inf1 -0.001  0.000 -0.394
p <- ggpredict(m, c("inMinOut","Info"))
Norm.Info.S1 <-ggplot(p, aes(x, predicted)) +  geom_line(aes(linetype=group, color=group)) + geom_ribbon(aes(ymin=conf.low, ymax=conf.high, fill=group), alpha=0.15) + scale_linetype_discrete(labels = c("Group Norms","No Group Norms")) + scale_color_manual(labels = c("Group Norms","No Group Norms"), values = wes_palette("Darjeeling1")) + scale_fill_manual( 
                      labels=c("Group Norms","No Group Norms"), values = wes_palette("Darjeeling1")) + theme(
    legend.position = c(.6, .20),
    legend.justification = c("left", "bottom"),
    legend.box.just = "left",
    legend.margin = margin(6, 6, 6, 6)
    ) + theme(axis.text=element_text(size=12),
        axis.title=element_text(size=12,face="bold")) + theme(legend.text = element_text(size=12)) + theme(panel.border = element_rect(colour = "black", fill = NA, size =1)) + theme(legend.title = element_blank()) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black")) +
  xlab("Inter-Party Favorability") + ylab("Approval Rating") + scale_y_continuous(breaks=seq(1,7,2)) + scale_x_continuous(breaks=seq(-1,1,1)) 
Norm.Info.S1

ggpredict(m, c("inMinOut","Info"))%>% plot(add.data=T) + labs(title="Raw Data",x="Inter-Party Favorability",y="Evaluation")

Study 2

m <- lmer( eval ~ inMinOut*Info + ( inMinOut | subID) + (1 | issues), data = longDf2, control=lmerControl(optimizer="bobyqa",
                                optCtrl=list(maxfun=2e5)))
summary(m)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: eval ~ inMinOut * Info + (inMinOut | subID) + (1 | issues)
##    Data: longDf2
## Control: lmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
## REML criterion at convergence: 350609.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.2083 -0.6302  0.0562  0.6536  3.7512 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr 
##  subID    (Intercept)  44.94    6.704        
##           inMinOut    538.14   23.198   -0.33
##  issues   (Intercept) 350.28   18.716        
##  Residual             627.06   25.041        
## Number of obs: 37549, groups:  subID, 380; issues, 100
## 
## Fixed effects:
##                Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)     56.7959     1.9097 104.2910  29.740  < 2e-16 ***
## inMinOut        30.2353     1.2478 376.9426  24.230  < 2e-16 ***
## Info1           -0.7493     0.3688 378.1852  -2.032  0.04285 *  
## inMinOut:Info1   3.9351     1.2501 377.3046   3.148  0.00178 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) inMnOt Info1 
## inMinOut    -0.055              
## Info1        0.003 -0.006       
## inMnOt:Inf1 -0.004  0.014 -0.290
p <- ggpredict(m, c("inMinOut","Info"))
Norm.Info.S2 <-ggplot(p, aes(x, predicted)) +  geom_line(aes(linetype=group, color=group)) + geom_ribbon(aes(ymin=conf.low, ymax=conf.high, fill=group), alpha=0.15) + scale_linetype_discrete(labels = c("Group Norms","No Group Norms")) + scale_color_manual(labels = c("Group Norms","No Group Norms"), values = wes_palette("Darjeeling1")) + scale_fill_manual( 
                      labels=c("Group Norms","No Group Norms"), values = wes_palette("Darjeeling1")) + theme(
    legend.position = c(.6, .20),
    legend.justification = c("left", "bottom"),
    legend.box.just = "left",
    legend.margin = margin(6, 6, 6, 6)
    ) + theme(axis.text=element_text(size=12),
        axis.title=element_text(size=12,face="bold")) + theme(legend.text = element_text(size=12)) + theme(panel.border = element_rect(colour = "black", fill = NA, size =1)) + theme(legend.title = element_blank()) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black")) +
  xlab("Issue Similarity") + ylab("Rating Dissimilarity")  + scale_x_continuous(breaks=seq(-1,1,1))
Norm.Info.S2

ggpredict(m, c("inMinOut","Info"))%>% plot(add.data=T) + labs(title="Raw Data",x="Inter-Party Favorability",y="Evaluation")

Combined

Norm.Info.Comb <- plotCommAxes(Norm.Info.S1, Norm.Info.S2, xaxis = "Inter-Party Favorability", yaxis = "Approval Rating")
Norm.Info.Comb

ggsave(paste0(plotswd,objectName(Norm.Info.Comb),".png"), width = 9, height = 6, dpi=500, units="in")
ggsave(paste0(plotswd,objectName(Norm.Info.Comb),".tiff"), width = 9, height = 6, dpi=500, units="in")

Affective Polarization

Study 1

m <- lmer( eval ~ inMinOut*affPol + ( inMinOut | subID) + (1 | issues), data = longDf1, control=lmerControl(optimizer="bobyqa",
                                optCtrl=list(maxfun=2e5)))
summary(m)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: eval ~ inMinOut * affPol + (inMinOut | subID) + (1 | issues)
##    Data: longDf1
## Control: lmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
## REML criterion at convergence: 140939.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.4298 -0.6336  0.0957  0.6610  4.3573 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr 
##  subID    (Intercept) 0.1237   0.3517        
##           inMinOut    1.5461   1.2434   -0.47
##  issues   (Intercept) 1.0434   1.0215        
##  Residual             2.3050   1.5182        
## Number of obs: 37817, groups:  subID, 383; issues, 100
## 
## Fixed effects:
##                   Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)      4.755e+00  1.084e-01  1.230e+02  43.859  < 2e-16 ***
## inMinOut         9.867e-01  1.237e-01  3.829e+02   7.978 1.74e-14 ***
## affPol          -8.214e-04  5.379e-04  3.797e+02  -1.527    0.128    
## inMinOut:affPol  2.089e-02  1.855e-03  3.838e+02  11.263  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) inMnOt affPol
## inMinOut    -0.124              
## affPol      -0.278  0.327       
## inMnOt:ffPl  0.101 -0.840 -0.392
p <- ggpredict(m, c("inMinOut","affPol"))
Norm.affPol.S1 <-ggplot(p, aes(x, predicted)) +  geom_line(aes(linetype=group, color=group)) + geom_ribbon(aes(ymin=conf.low, ymax=conf.high, fill=group), alpha=0.15) + scale_linetype_discrete(labels = c("Low Aff. Pol.","Medium Aff. Pol.", "High Aff. Pol.")) + scale_color_manual(labels = c("Low Aff. Pol.","Medium Aff. Pol.", "High Aff. Pol."), values = wes_palette("Darjeeling1")) + scale_fill_manual( 
                      labels=c("Low Aff. Pol.","Medium Aff. Pol.", "High Aff. Pol."), values = wes_palette("Darjeeling1")) + theme(
    legend.position = c(.6, .20),
    legend.justification = c("left", "bottom"),
    legend.box.just = "left",
    legend.margin = margin(6, 6, 6, 6)
    ) + theme(axis.text=element_text(size=12),
        axis.title=element_text(size=12,face="bold")) + theme(legend.text = element_text(size=12)) + theme(panel.border = element_rect(colour = "black", fill = NA, size =1)) + theme(legend.title = element_blank()) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black")) +
  xlab("Inter-Party Favorability") + ylab("Approval Rating")  + scale_x_continuous(breaks=seq(-1,1,1)) + scale_y_continuous(breaks=seq(1,7,2))
Norm.affPol.S1

ggpredict(m, c("inMinOut","affPol"))%>% plot(add.data=T) + labs(title="Raw Data",x="Inter-Party Favorability",y="Evaluation")

Study 2

m <- lmer( eval ~ inMinOut*affPol + ( inMinOut | subID) + (1 | issues), data = longDf2, control=lmerControl(optimizer="bobyqa",
                                optCtrl=list(maxfun=2e5)))
summary(m)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: eval ~ inMinOut * affPol + (inMinOut | subID) + (1 | issues)
##    Data: longDf2
## Control: lmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
## REML criterion at convergence: 350506.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.2341 -0.6306  0.0558  0.6539  3.6990 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr 
##  subID    (Intercept)  43.1     6.565        
##           inMinOut    380.2    19.500   -0.23
##  issues   (Intercept) 338.0    18.385        
##  Residual             627.1    25.041        
## Number of obs: 37549, groups:  subID, 380; issues, 100
## 
## Fixed effects:
##                  Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)      58.88778    1.95105 122.21960  30.183  < 2e-16 ***
## inMinOut         10.41790    1.93358 378.28310   5.388 1.26e-07 ***
## affPol           -0.04348    0.01031 377.97543  -4.217 3.10e-05 ***
## inMinOut:affPol   0.37797    0.03082 378.48039  12.262  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) inMnOt affPol
## inMinOut    -0.057              
## affPol      -0.276  0.156       
## inMnOt:ffPl  0.045 -0.834 -0.191
p <- ggpredict(m, c("inMinOut","affPol"))
Norm.affPol.S2 <-ggplot(p, aes(x, predicted)) +  geom_line(aes(linetype=group, color=group)) + geom_ribbon(aes(ymin=conf.low, ymax=conf.high, fill=group), alpha=0.15) + scale_linetype_discrete(labels = c("Group Norms","No Group Norms")) + scale_color_manual(labels = c("Group Norms","No Group Norms"), values = wes_palette("Darjeeling1")) + scale_fill_manual( 
                      labels=c("Group Norms","No Group Norms"), values = wes_palette("Darjeeling1")) + theme(
    legend.position = c(.6, .20),
    legend.justification = c("left", "bottom"),
    legend.box.just = "left",
    legend.margin = margin(6, 6, 6, 6)
    ) + theme(axis.text=element_text(size=12),
        axis.title=element_text(size=12,face="bold")) + theme(legend.text = element_text(size=12)) + theme(panel.border = element_rect(colour = "black", fill = NA, size =1)) + theme(legend.title = element_blank()) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black")) +
  xlab("Inter-Party Favorability") + ylab("Approval Rating")  + scale_x_continuous(breaks=seq(-1,1,1)) 
Norm.affPol.S2

ggpredict(m, c("inMinOut","affPol"))%>% plot(add.data=T) + labs(title="Raw Data",x="Inter-Party Favorability",y="Evaluation")

Combined

Norm.affPol.Comb <- plotCommAxes(Norm.affPol.S1, Norm.affPol.S2, xaxis = "Inter-Party Favorability", yaxis = "Approval Rating")
Norm.affPol.Comb

ggsave(paste0(plotswd,objectName(Norm.affPol.Comb),".png"), width = 9, height = 6, dpi=500, units="in")
ggsave(paste0(plotswd,objectName(Norm.affPol.Comb),".tiff"), width = 9, height = 6, dpi=500, units="in")
Norm.Comb <- ggarrange(Norm.affPol.Comb, Norm.Info.Comb, nrow = 2, ncol = 1)
Norm.Comb

ggsave(paste0(plotswd,objectName(Norm.Comb),".png"), width = 10, height = 9, dpi=500, units="in")
ggsave(paste0(plotswd,objectName(Norm.Comb),".tiff"), width = 10, height = 9, dpi=500, units="in")